package com.example.springboot_study.service.impl;

import com.example.springboot_study.dao.primary.UserMapper;
import com.example.springboot_study.entity.primary.User;
import com.example.springboot_study.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : liqun
 * @createTime : 2021/9/10 16:12
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public int create(String name, Integer age) {
        return userMapper.insert(name,age);
    }

    @Override
    public List<User> getByName(String name) {
        return userMapper.findByName(name);
    }

    @Override
    public int deleteByName(String name) {
        return userMapper.deleteByName(name);
    }

    @Override
    public List<User> getAllUsers() {
        return userMapper.findAll();
    }

    @Override
    public int deleteAllUsers() {
        return userMapper.deleteAll();
    }
}
